{extend name="index/index"}
{block name="content"}
<div class="tpl-content-wrapper">
    <div class="tpl-content-page-title">
        Amaze UI 文字列表
    </div>
    <ol class="am-breadcrumb">
        <li><a href="#" class="am-icon-home">首页</a></li>
        <li><a href="#">Amaze UI CSS</a></li>
        <li class="am-active">文字列表</li>
    </ol>
    <div class="tpl-portlet-components">
        <div class="portlet-title">
            <div class="caption font-green bold">
                <span class="am-icon-code"></span> 列表
            </div>
            <div class="tpl-portlet-input tpl-fz-ml">
                <div class="portlet-input input-small input-inline">
                    <div class="input-icon right">
                        <i class="am-icon-search"></i>
                        <input type="text" class="form-control form-control-solid" placeholder="搜索..."> </div>
                </div>
            </div>


        </div>
        <div class="tpl-block">
            <div class="am-g">
                <div class="am-u-sm-12 am-u-md-6">
                    <div class="am-btn-toolbar">
                        <div class="am-btn-group am-btn-group-xs">
                            <!-- <button type="button" class="am-btn am-btn-default am-btn-success"><span class="am-icon-plus"></span> 新增</button> -->
                            <button type="button" class="am-btn am-btn-default am-btn-success" data-am-modal="{target: '#doc-modal-1', closeViaDimmer: 0, width: 400, height: 225}"><span class="am-icon-plus"></span> 新增</button>
                            <button type="button" class="am-btn am-btn-default am-btn-secondary"><span class="am-icon-save"></span> 保存</button>
                            <button type="button" class="am-btn am-btn-default am-btn-warning"><span class="am-icon-archive"></span> 审核</button>
                            <button type="button" class="am-btn am-btn-default am-btn-danger"><span class="am-icon-trash-o"></span> 删除</button>
                        </div>
                    </div>
                </div>
                <div class="am-u-sm-12 am-u-md-3">
                    <div class="am-form-group">
                        <select data-am-selected="{btnSize: 'sm'}">
      <option value="option1">所有类别</option>
      <option value="option2">IT业界</option>
      <option value="option3">数码产品</option>
      <option value="option3">笔记本电脑</option>
      <option value="option3">平板电脑</option>
      <option value="option3">只能手机</option>
      <option value="option3">超极本</option>
    </select>
                    </div>
                </div>
                <div class="am-u-sm-12 am-u-md-3">
                    <div class="am-input-group am-input-group-sm">
                        <input type="text" class="am-form-field">
                        <span class="am-input-group-btn">
    <button class="am-btn  am-btn-default am-btn-success tpl-am-btn-success am-icon-search" type="button"></button>
  </span>
                    </div>
                </div>
            </div>
            <div class="am-g">
                <div class="am-u-sm-12">
                    <!-- <form class="am-form"> -->
                        <table class="am-table am-table-striped am-table-hover table-main">
                            <thead>
                                <tr>
                                    <th class="table-check"><input type="checkbox" class="tpl-table-fz-check"></th>
                                    <th class="table-id">ID</th>
                                    <th class="table-title">角色</th>
                                    <th class="table-date am-hide-sm-only">修改日期</th>
                                    <th class="table-set">操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                {volist name="list" id="v"}
                                <tr>
                                    <td><input type="checkbox"></td>
                                    <td>{$v['id']}</td>
                                    <td><a href="#">{$v['name']}</a></td>
                                    <td class="am-hide-sm-only">2014年9月4日 7:28:47</td>
                                    <td>
                                        <div class="am-btn-toolbar">
                                            <div class="am-btn-group am-btn-group-xs">
                                                <button class="am-btn am-btn-default am-btn-xs am-text-secondary"><span class="am-icon-pencil-square-o"></span> <a href="{:url('admin/Actor/edit', ['id'=>$v['id']])}">编辑</a></button>
                                                <button class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only del-btn" data-id="{$v['id']}"><span class="am-icon-trash-o"></span> 删除</button>
                                                <button class="am-btn am-btn-default am-btn-xs am-hide-sm-only am-text-warning"><a href="{:url('admin/Actor/read', ['id'=>$v['id']])}">权限</a></button>

                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                {/volist}
                            </tbody>
                        </table>
                        <div class="am-cf">

                            <div class="am-fr">
                                <ul class="am-pagination tpl-pagination">
                                    <li><a href="/actor.html?page=1">«</a></li>
                                    <li><a href="/actor.html?page=1">1</a></li>
                                    <li><a href="/actor.html?page=2">2</a></li>
                                    <li><a href="/actor.html?page=2">»</a></li>
                                </ul>
                            </div>
                        </div>
                        <hr>

                    <!-- </form> -->
                </div>

            </div>
        </div>
        <div class="tpl-alert"></div>
    </div>










</div>

<div class="am-modal am-modal-no-btn" tabindex="-1" id="doc-modal-1">
  <div class="am-modal-dialog">
    <div class="am-modal-hd">添加用户
      <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
    </div>
    <div class="am-modal-bd">
        <form action="{:url('admin/Actor/save')}" method="post">
            <input type="text" name="name" placeholder="输入角色">
            <input type="submit" value="添加" class="am-btn am-btn-default am-btn-success">
        </form>
    </div>
  </div>
</div>


<script src="/assets/js/jquery.min.js"></script>
{js href="/static/toastr.min.js"}
<script>

    // 设置弹框参数
    toastr.options = {
        closeButton: true,// 是否显示关闭按钮
        progressBar: true,// 实现显示计时条
        timeOut: "3000",  // 自动关闭时间
        positionClass: "toast-bottom-left" // 提示位置
        // toast-top-full-width 顶端，宽度铺满整个屏幕
        // toast-top-right  顶端右边
    };

    $(function(){
        // 删除动作
        $('.del-btn').click(function(){
            var ac_id = $(this).attr('data-id');
            console.log('删除ID: '+ ac_id);

            if (confirm('您确定要 [ 删除 ]吗?')) {
                var obj = $(this).parents('tr');
                console.log(obj)
                // 处理删除
                // toastr.success('123424324');
                delAjax(ac_id, obj);
            }
        });
        // 查询单个用户动作
        $('.show-btn').click(function(){
            var ac_id = $(this).attr('data-id');
            console.log('查询ID: '+ ac_id);

            showAjax(ac_id);
        });


    });


    function showAjax(id) {
        $.ajax({
            type: 'get',
            url : '/Power/'+id,
            dataType: 'json',
            success : function (data){
                console.log(data);
                // if (data.status) {

                //     $('.modal-title u').html(data.title);
                //     var msg = data.datas.name + '/'+data.datas.tel;
                //     $('.modal-body h3').html(msg);
                // } else {
                //     $('.modal-title u').html(data.title);
                //     $('.modal-body h3').html(data.datas);
                // }
            },
            error:function(){
                alert('AJAX操作失败!');
            }
        });
    }



    /**
     *
     * @param id   主键
     * @param obj  tr行对象
     */
    function delAjax(id, obj) {
        $.ajax({
            type: 'delete',
            url : '/actor/'+id,
            dataType: 'json',
            success : function (data){
                console.log(data);
                if (data.status) {
                    toastr.success('123424324');
                    obj.remove();
                } else {
                    toastr.error(data.info, 'FBI WARING:');
                }
            },
            error:function(){
                alert('AJAX操作失败!');
            }
        });
    }

</script>
{/block}


